<h1>客户管理 - <span id="secondHeading">增加客户</span></h1>
<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "util" %>
<%= javascript_include_tag "calendar" %>
<script type="text/javascript">
        function checkName(flag){
                if (flag) {
                        if ($("agent_name").value == "")
                        {
                                $("id_name").innerText = "客户名不可为空";
                                $("id_name").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_name").style.display = "none";
                }
        }
        function checkMSN(flag){
                if (flag) {
                        if ($("agent_msn").value != "" && ! checkEmail($("agent_msn").value))
                        {
                                $("id_msn").innerText = "MSN地址不正确";
                                $("id_msn").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_msn").style.display = "none";
                }
        }
        function checkMail(flag){
                if (flag) {
                        if ($("agent_email").value != "" && ! checkEmail($("agent_email").value))
                        {
                                $("id_email").innerText = "邮件地址不正确";
                                $("id_email").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_email").style.display = "none";
                }
        }
        function checkNum(flag, msg_id, obj_name, msg_text){
                if (flag) {
                        if ($(obj_name).value != "" && ! digCheck($(obj_name).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }

	function checkForm(){
                return checkName(true) && checkMSN(true) && checkMail(true) && checkNum(true,'id_QQ','agent_QQ','QQ号码输入错误');
	}
</script>
<%= form_tag({}, :id => "input-form")%>
<TABLE border="0" id="INPUT_TABLE">
	<TR>
		<TD colspan="2">
			<% if @flash[:notice] -%>
			<div id="notice"><%= @flash[:notice] %></div>
			<% end -%>
		</TD>
	</TR>
    <tr>
      <td>客户名：</td>
      <td><%= text_field("agent", "name",:size=>"30", :maxlength => "20", :onfocus => "checkName(false)", :onblur=>"checkName(true)") %>          <em>*</em> <div class="redNsg" id="id_name" style="display:none;"></div></td>
    </tr>
    <tr>
      <td>所属地区：</td>
      <td><%= text_field("agent", "part",:size=>"30") %></td>
    </tr>
    <tr>
      <td>联系人：</td>
      <td><%= text_field("agent", "person",:size=>"30") %></td>
    </tr>
    <tr>
      <td>性别：</td>
      <td><%= select(:agent, :sex, [ ['女', 0],['男', 1] ])%></td>
    </tr>
    <tr>
      <td>生日：</td>
      <td>
                <script language=javascript>
                        var bir_Date=new dateSelector();
                        bir_Date.inputID='birthday_on';
                        bir_Date.inputName='agent[birthday_on]';
                        bir_Date.display();
                </script>
        </td>
    </tr>
    <tr>
      <td>电话：</td>
      <td><%= text_field("agent", "phone",:size=>"30") %></td>
    </tr>
    <tr>
      <td>手机：</td>
      <td><%= text_field("agent", "mobile",:size=>"30") %></td>
    </tr>
    <tr>
      <td>小灵通：</td>
      <td><%= text_field("agent", "lingtong",:size=>"30") %></td>
    </tr>
    <tr>
      <td>传真：</td>
      <td><%= text_field("agent", "fax",:size=>"30") %></td>
    </tr>
    <tr>
      <td>地址：</td>
      <td><%= text_field("agent", "address1",:size=>"30") %></td>
    </tr>
    <tr>
      <td>备用地址：</td>
      <td><%= text_field("agent", "address2",:size=>"30") %></td>
    </tr>
    <tr>
      <td>QQ：</td>
      <td><%= text_field("agent", "qq",:size=>"30", :onfocus => "checkNum(false,'id_QQ')", :onblur=>"checkNum(true,'id_QQ',this.name,'QQ号码输入错误')")  %><div class="redNsg" id="id_QQ" style="display:none;"></div></td>
    </tr>
    <tr>
      <td>MSN：</td>
      <td><%= text_field("agent", "msn",:size=>"30", :onfocus => "checkMSN(false)", :onblur=>"checkMSN(true)")  %><div class="redNsg" id="id_msn" style="display:none;"></div></td>
    </tr>
    <tr>
      <td>邮件地址：</td>
      <td><%= text_field("agent", "email",:size=>"30", :onfocus => "checkMail(false)", :onblur=>"checkMail(true)")  %><div class="redNsg" id="id_email" style="display:none;"></div></td>
    </tr>
    <tr>
      <td>个人爱好：</td>
      <td><%= text_field("agent", "favor",:size=>"30") %></td>
    </tr>
    <tr>
      <td>备用联系人：</td>
      <td><%= text_field("agent", "second_person",:size=>"30") %></td>
    </tr>
    <tr>
      <td>备用联系人电话：</td>
      <td><%= text_field("agent", "second_phone",:size=>"30") %></td>
    </tr>
    <tr>
      <td>备注：</td>
      <td><textarea id="agent_memo" name="agent[memo]" cols="50" rows="5"></textarea></td>
    </tr>
    <tr>
      <td colspan="2" align="right">
      <input type="submit" value="添加" class="sub" onclick="javascript:return checkForm();">&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal"></td>
    </tr>
</table>
 <p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项。
 </p>
<%= end_form_tag %>
